-
Notifications
You must be signed in to change notification settings - Fork 86
Updates to task / task list design - #553 #554 #555 #557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Also added: * task list filtering for tasks API * automatically create task lists on project creation - #553 Still remaining: * Implementing APIs and views * Implementing tests
Modified project API / view to return task lists Modified tasks API to order by rank instead of inserted date Modified tasks API / view to return task list Added task list API / view to get all / single task lists
|
@joshsmith - this should be ready to review now. Feel free to pull in whoever else you think needs to review this. |
|
🎉 thanks @green-arrow. Now that I've spent the past 8 hours or so exploring this problem top-to-bottom, thinking this looks pretty good, but now need to review more thoroughly. I'm going to be playing around with a quick-and-dirty client implementation and then test out how well these will play together. Stay tuned for a more thorough review. If you wanted to move on to something else, please feel free. |
joshsmith
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, have some thoughts we can discuss:
lib/code_corps/helpers/query.ex
Outdated
| def project_id_with_number_filter(query, _), do: query | ||
|
|
||
| def task_list_id_with_number_filter(query, %{"id" => number, "task_list_id" => task_list_id}) do | ||
| IO.puts "YAY" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs removed.
lib/code_corps/helpers/query.ex
Outdated
| task_list_ids = task_list_ids |> coalesce_id_string | ||
| query |> where([object], object.task_list_id in ^task_list_ids) | ||
| end | ||
| def task_list_filter(query, %{"task_list_id" => task_list_id}) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this one is necessary. See the id_filter for what I mean.
lib/code_corps/helpers/query.ex
Outdated
|
|
||
| def sort_by_newest_first(query), do: query |> order_by([desc: :inserted_at]) | ||
|
|
||
| def sort_by_rank(query), do: query |> order_by([asc: :rank]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this desc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we want rank to be ascending (lower numbers are at the top of the list).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, you're right. sorry.
| |> put_assoc(:task_lists, TaskList.default_task_lists()) | ||
| |> Repo.update | ||
|
|
||
| add_existing_tasks_to_inbox(project, hd(project.task_lists)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is hd()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hd/1 refers to the first item in the list, the head. (Also, tl/1 refers to the last item, the tail)
| |> Enum.map(&Integer.parse/1) | ||
| |> Enum.map(fn({id, _rem}) -> id end) | ||
|
|
||
| assert ids == [task_list_2.id, task_list_1.id, task_list_3.id] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we had some id assertion helpers in other controller tests.
test/views/task_list_view_test.exs
Outdated
| task_list_b = insert(:task_list, rank: 500, project: project) | ||
| task = insert(:task, rank: 1000, task_list: task_list_a) | ||
|
|
||
| rendered_json = render(CodeCorps.TaskListView, "show.json-api", data: [task_list_a, task_list_b]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just render the show here? Seems simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I.e. just one task list, not two.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I was working on seeing if I could work with position in the return and needed multiple items to verify. Since that's not how this works (rank is returned) we can go back to just one.
test/views/project_view_test.exs
Outdated
| "data" => [%{ | ||
| "id" => task_list.id |> Integer.to_string, | ||
| "type" => "task-list" | ||
| }] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer formatting like below with tasks.
test/views/task_view_test.exs
Outdated
| "task-type" => task.task_type, | ||
| "title" => task.title, | ||
| "updated-at" => task.updated_at, | ||
| "rank" => task.rank |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alpha-order here.
web/controllers/task_controller.ex
Outdated
| end | ||
|
|
||
| def record(%Plug.Conn{params: %{"task_list_id" => _task_list_id} = params}, _number_as_id) do | ||
| IO.inspect params |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To remove.
web/models/task.ex
Outdated
| |> validate_inclusion(:task_type, task_types) | ||
| |> assoc_constraint(:task_list) | ||
| |> apply_position() | ||
| |> set_order(:position, :rank, :task_list_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This further makes me think order is the right name here.
|
@joshsmith - I gave a 👍 to all the things I fixed and left a couple comments in other places. |
|
Looks great! Going to squash and merge if you're ready! |
|
Have at it! |
What's in this PR?
Redesigned API to account for the newly updated task list / task front end.
References
Progress on: #554 #553 #555
Total progress